package com.gps.pe.exception;

import java.util.Map;

/**
 * Validator of data processed in service layer.
 * 
 * @author GPS
 *
 * @param <T>
 */
public interface Validator<T> {

	public ValidationResult validate(T object) throws ServiceException;

	public ValidationResult validate(T object, Map<String, Object> params) throws ServiceException;

	/**
	 * Validates object on deletion (makes sure that object can be deleted and
	 * does not break any constraints)
	 * 
	 * @param object
	 *            deleted object
	 * @param configuration
	 *            configuration descriptor
	 * @return result of validation
	 * @throws ServiceException
	 */
	public ValidationResult validateOnDelete(T object) throws ServiceException;

	/**
	 * Validates object on edit (makes sure that object can be edited and does
	 * not break any constraints)
	 * 
	 * @param object
	 *            edited object
	 * @param configuration
	 *            configuration descriptor
	 * @return result of validation
	 * @throws ServiceException
	 */
	public ValidationResult validateOnChange(T object) throws ServiceException;

	/**
	 * Clears validation errors.
	 */
	public void clearErrors();
}
